<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>定义</title>
    <link rel="stylesheet" href="../frame/layui/css/layui.css">
    <link rel="stylesheet" href="../frame/static/css/style.css">
    <link rel="icon" href="../frame/static/image/code.png">
</head>
<body class="body">

<table class="layui-table">
    <colgroup>
        <col width="150">
        <col width="150">
        <col width="200">
        <col>
    </colgroup>
    <thead>
    <tr>
    	<th colspan="4" id='reqName'></th>
    </tr>
    <tr>
        <th>修饰符</th>
        <th>类型定义</th>
        <th>名称</th>
        <th>注释</th>
    </tr>
    </thead>
    <tbody id='req'>
    	
    </tbody>
</table>

<table class="layui-table">
    <colgroup>
        <col width="150">
        <col width="150">
        <col width="200">
        <col>
    </colgroup>
    <thead>
    <tr>
    	<th colspan="4" id='rspName'></th>
    </tr>
    <tr>
        <th>修饰符</th>
        <th>类型定义</th>
         <th>名称</th>
        <th>注释</th>
    </tr>
    </thead>
    <tbody id='rsp'>
    	
    </tbody>
</table>


<script type="text/javascript" src="../frame/layui/layui.js"></script>
<script type="text/javascript" src="../js/index.js"></script>
<script type="text/javascript" src="../js/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
var refs ={};
layui.use(['table', 'form', 'layer', 'vip_table'], function () {
    // 操作对象
    var form = layui.form
            , table = layui.table
            , layer = layui.layer
            , vipTable = layui.vip_table
            , $ = layui.jquery;
});
function reset(obj) {
    $('#reqName').html('请求参数：'+obj.req.name + "</br>");
    $('#rspName').html('返回参数：'+obj.rsp.name + "</br>");
    var i =0;
    var field = obj.req['field' +i];
    var req = '';
    while(field !=null||field!=undefined){
    	req = req + '<tr><td>'+field.option+'</td>' ;
    	var ref = field.refObj;
    	if(ref !=null&&ref!=undefined){    
    		refs[ref.name] = ref;
    		req = req + '<td><a href="javascript:openRef(\''+ref.name+'\')" style="text-decoration:underline;">'+field.type+'</a></td>';
    	}else{
    		req = req + '<td>'+field.type+'</td>';
    	}
    	req = req + '<td>'+field.name+'</td>'+ '<td>'+field.commont+'</td><tr>';
    	i++;
    	field = obj.req['field' +i];
    }
    $('#req').html(req);
    i =0;
    //alert(JSON.stringify(obj.rsp));
    field = obj.rsp['field' +i];
    var rsp = '';
    while(field !=null||field!=undefined){
    	rsp = rsp + '<tr><td>'+field.option+'</td>' ;
    	var ref = field.refObj;
    	if(ref !=null||ref!=undefined){    		
    		refs[ref.name] = ref;
    		rsp = rsp + '<td><a href="javascript:openRef(\''+ref.name+'\')" style="text-decoration:underline;">'+field.type+'</a></td>';
    	}else{
    		rsp = rsp + '<td>'+field.type+'</td>';
    	}
    	rsp = rsp + '<td>'+field.name+'</td>'+ '<td>'+field.commont+'</td><tr>';
    	i++;
    	field = obj.rsp['field' +i];
    }
    $('#rsp').html(rsp);
}
function openRef(name){
	var data =refs[name]
	var idx = layer.open({
		  type: 2,
		  title:'服务定义',
		  area: ['700px', '800px'],
		  fixed: false, //不固定
		  maxmin: true,
		  content: '/page/pbMessgae.html',
		  success: function (layero, index) {
                // 获取子页面的iframe
                var iframe = window['layui-layer-iframe' + index];
                // 向子页面的全局函数child传参
                iframe.reset(data);
		  }
	});
	layer.full(idx);
}
</script>
</body>
</html>